package cn.gs;

import cn.gs.entity.User;
import cn.gs.service.UserServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 *
 * 应用推荐
 * **/
@Configuration // 声明为配置类
@ComponentScan("cn.gs") // 扫描当前包及子包 // 必须显式声明
public class ApplicationRecommended {

    public static void main(String[] args) {
        ApplicationContext context =
                new AnnotationConfigApplicationContext(ApplicationRecommended.class);

        UserServiceImpl userService =
                context.getBean(UserServiceImpl.class);

        List<User> users = userService.findUserList();

        users.forEach(a -> System.out.println("推荐启动类为配置类："+a.getName() + "," + a.getAge() + "," + a.getRemark()));

    }
}
